# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=postgresql-age
pkgver=1.5.0
# This is a stable release, upstream just uses confusing naming.
_pkgver="${pkgver}-rc0"
pkgrel=0
pkgdesc="Graph database optimized for fast analysis and real-time data processing"
url="https://github.com/apache/age"
arch="all"
license="Apache-2.0 AND PostgreSQL"
_pgver=16
makedepends="
	bison
	flex
	perl
	postgresql$_pgver-dev
	"
subpackages="$pkgname-bitcode"
source="https://github.com/apache/age/archive/PG$_pgver/v$_pkgver/postgresql-age-$_pkgver.tar.gz"
builddir="$srcdir/age-PG$_pgver-v$_pkgver"
options="!check"  # tests require running PostgreSQL

build() {
	make -j1
}

package() {
	depends="postgresql$(pg_config --major-version)"

	make DESTDIR="$pkgdir" install
}

bitcode() {
	pkgdesc="$pkgdesc (bitcode for JIT)"
	depends="$pkgname=$pkgver-r$pkgrel"
	install_if="postgresql$(pg_config --major-version)-jit $pkgname=$pkgver-r$pkgrel"

	amove usr/lib/postgresql*/bitcode
}

sha512sums="
105485cea2b98153d4b3a146dc55a87fd7c46c4104c5732bf925933e33220c82fc57381cf9bd82c591a7dc9cd643df197bf38ea92b56a2b7f97486f7fb6f00ef  postgresql-age-1.5.0-rc0.tar.gz
"
